//
//  CatchErrorJustReturnViewController.swift
//  testRxSwift
//
//  Created by 火星人 on 2017/7/25.
//  Copyright © 2017年 火星人. All rights reserved.
//

import UIKit
import RxSwift

class CatchErrorJustReturnViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addTapWithHandle { (tap) in
            
            enum TestError: Error {
                case test
            }
            
            let bag = DisposeBag()
            
            let subject = PublishSubject<Int>()
            
            subject.catchErrorJustReturn(-1)
                .subscribe({ (eve) in
                    print(eve)
                })
                .disposed(by: bag)
            
            subject.onNext(1)
            subject.onNext(2)
            subject.onError(TestError.test)
        }
    }
}
